package com.wenda.homeschooedu.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.wenda.homeschooedu.biz.LessonManager;

public class LessonServlet extends HttpServlet {
	/**
	 * 版本1
	 */
	private static final long serialVersionUID = 1L;
	
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		PrintWriter out = null ;
		String result = "";
		if (request.getParameter("format")!=null) {
			if (request.getParameter("format").equals("json")) {
				response.setContentType("text/html;charset=utf-8");
				out = response.getWriter();
				if (request.getParameter("type").equals("get")) {
					int class_id = Integer.parseInt(request.getParameter("class_id"));
					int year = Integer.parseInt(request.getParameter("year"));
					int term = Integer.parseInt(request.getParameter("term"));
				
					
					
					System.out.println(class_id+"  "+ year+"  "+term+"  ");
					
					
					LessonManager manager = new LessonManager();
					result = manager.getLessonListByClassToJson(class_id, year, term);
				}
			}
		}
		
		out.println(result);
		out.flush();
		out.close();
		
			
	}
	
	
	
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		this.doGet(request, response);
	}
	
	
	
	
}
